package com.example.springbootpro.controller.oracle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/oracle")
public class OracleTestController {

    @Autowired
    @Qualifier("oracleJdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    @GetMapping("/prescription/{cfsb}")
    public List<Map<String, Object>> getPrescriptionDetails() {

        String sql = """
            select jssj, (select mzhm from ms_brda where brid=brbh),(select brxm from ms_brda where brid=brbh),(select ygxm from gy_ygdm where ygdm=ysdm)  from ys_mz_jzls
                                                                                where jssj>=date'2025-04-01' and jssj<date'2025-05-01'
                                                                                and jzzt=9\s
                                                                                and jzxh not in
                                                                                (select distinct jzxh from  omr_bl01 e,omr_bl02 f where e.blbh=f.blbh and jlsj>=date'2025-04-01' and jlsj<date'2025-05-01'\s
                                                                               and ( blmc like '%中医门诊%' or  blmc like '%门诊病历%' or  blmc like '%门诊复诊%' or  blmc like '%急诊病历%') )
                                                                               order by jssj asc
            """;
        return jdbcTemplate.queryForList(sql);
    }
}